package string;

import java.util.Locale;
import java.util.Random;
import java.util.Scanner;

public class Captchatest {
    public static void main(String[] args) {
        Random r=new Random();
        StringBuilder captcha=new StringBuilder();
        String str="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        for (int i=0;i<=5;i++){
            int ran=r.nextInt(str.length());

            captcha.append(str.charAt(ran));
        }
        System.out.println("你的验证码为"+captcha);
        System.out.println("请根据提示输入你的验证码");
        Scanner s=new Scanner(System.in);
        String num=s.next();
        String cap=num.substring(0,6);//截取6位验证码
        String captcha1=captcha.toString();
        String upper=captcha1.toUpperCase();
        String cap1=cap.toUpperCase();
        if(cap1.equals(upper)){
            System.out.println("验证成功");

        }else{
            System.out.println("验证失败");
        }
    }
}
